const Koa = require("koa");
const Router = require("koa-router");
const bodyparser = require("koa-bodyparser");
const cors = require("koa-cors");

const app = new Koa();
const router = new Router();

let count = 0;

router.get("/test", async (ctx, next) => {
  console.log(count);
  ctx.body = {
    code: 200,
    count: count++,
  };
});
app.use(cors());
app.use(bodyparser());
app.use(router.routes()).use(router.allowedMethods());

app.listen(3000, () => {
  console.log("3000端口已监听");
});
